﻿using System;
using System.Collections.Generic;
using System.Text;
using SimpleFS.Core;
using SimpleFS.Core.Implementations;
using SimpleFS.Services.Transactions.Implementations;
using SimpleFS.Services.Transactions.Implementations.Files;

namespace SimpleFS.Services.Transactions
{
    public class File : AbstractFile
    {
        internal IFile internalObject;

        internal IResourceManager resourceManager = null;

        public File(IFile internalObject, IResourceManager resourceManager) : base(internalObject)
        {            
            this.resourceManager = resourceManager;
        }

        #region IFile Members

        public override void Write(System.IO.Stream stream)
        {
            SimpleFS.Services.Transactions.Implementations.Files.Write write
                = new SimpleFS.Services.Transactions.Implementations.Files.Write(
                    this.internalObject, stream, this.resourceManager);
            write.Execute();
        }

        #endregion

        #region IFileSystemObject Members

        public override void Delete()
        {
            SimpleFS.Services.Transactions.Implementations.Delete delete
                = new SimpleFS.Services.Transactions.Implementations.Delete(
                    this.internalObject, this.resourceManager);
            delete.Execute();
        }

        public override void Rename(string newName)
        {
            SimpleFS.Services.Transactions.Implementations.Rename rename
                = new SimpleFS.Services.Transactions.Implementations.Rename(
                    this.internalObject, newName, this.resourceManager);
            rename.Execute();
        }

        #endregion
    }
}
